package game;

import java.awt.Color;
import java.awt.Point;

public class Teleporter extends ActionField {
	private static final long serialVersionUID = 1L;
	private Teleporter tele;
	
	public Teleporter(Level l, int x, int y, int w, int h, Color c){
		super(l,x,y,w,h,c);
	}
	
	public void setTeleporter(Teleporter t){
		tele = t;
	}
	
	public void act(Sprite s){
		if(tele != null){
			s.x = tele.getWarpCoords(s).x;
			s.y = tele.getWarpCoords(s).y;
			s.prevX = tele.getWarpCoords(s).x;
			s.prevY = tele.getWarpCoords(s).y;
			Object[] temp = {true,true,s};
			tele.addInfo(temp);
			System.out.println("Warp");
		}
	}
	
	public Point getWarpCoords(Sprite s){
		return new Point((width-s.width)/2+x, (height-s.height)/2+y);
	}
}
